package edu.java.homework.hw09.exercises.nikolay.food.salad;


import edu.java.homework.hw09.exercises.nikolay.food.product.Product;
import edu.java.homework.hw09.exercises.nikolay.food.product.SpiceProduct;
import edu.java.homework.hw09.exercises.nikolay.food.product.VegetableProduct;

public abstract class SaladFactory {

	// --- Constants -----------------------------------------------------------

	protected static final String COMMA = "; ";

	// --- Constructors --------------------------------------------------------

	protected SaladFactory() {
	}

	// --- Methods (Template Method) -------------------------------------------

	public final Salad prepareSalad() {
		Salad salad = initSalad();		
		washProducts(salad);
		cutProducts(salad);
		boilProducts(salad);
		grateProducts(salad);
		mixProducts(salad);
		return salad;
	}

	protected abstract Salad initSalad();

	protected abstract void washProducts(Salad salad);

	protected abstract void cutProducts(Salad salad);

	protected abstract void boilProducts(Salad salad);

	protected abstract void grateProducts(Salad salad);

	protected abstract void mixProducts(Salad salad);

	// --- Methods -------------------------------------------------------------

	protected VegetableProduct[] getVegetables() {
		return null;
	}

	protected SpiceProduct[] getSpices() {
		return null;
	}

	protected void printSemicolonSeparatedList(Product[] products) {
		if (products == null) {
			throw new IllegalArgumentException(
					"Invalid argument - products: null.");
		}
		for (Product product : products) {
			System.out.print(product + COMMA);
		}
	}
}
